"""
Example demonstrating how to use registered ClassifierAlignment with DIL_Frame.
"""

import logging
from typing import List
from learners.registry import create_classifier_alignment, list_classifier_alignments
from learners.strategies.clfAlign.classifier_alignment import ClassifierAlignment


def example_usage() -> None:
    """Show how to use the ClassifierAlignment component through the registry."""

    # List available classifier alignment strategies
    available_alignments: List[str] = sorted(list_classifier_alignments())
    print(f"Available classifier alignment strategies: {available_alignments}")

    # Create the alignment component using the factory
    alignment: ClassifierAlignment = create_classifier_alignment(
        "standard",  # The registered name
        epochs=15,  # Custom parameter
        lr=0.005,  # Custom parameter
    )

    print("Successfully created ClassifierAlignment instance through registry")
    print(f"Created alignment instance: {type(alignment).__name__}")

    # Example of how this would be used with a learner
    # (in practice, this would be inside a learner initialization)
    """
    class MyLearner:
        def __init__(self, args, data_manager, ...):
            # ...other initialization...

            # Load classifier alignment from registry using args
            if args.get("use_classifier_alignment", False):
                alignment_type = args.get("classifier_alignment", "standard")
                self.alignment: ClassifierAlignment = create_classifier_alignment(
                    alignment_type,
                    epochs=args.get("ca_epochs", 20),
                    lr=args.get("ca_lr", 0.01)
                )
                # Register with hook system
                self.alignment.register_hooks(self)
    """


if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO)
    example_usage()
